\chapter{The Physical Environment}
\label{cha:environment}

\section{Overview}

Wireless networks are heavily affected by the physical environment, and the
requirements for today's ubiquitous wireless communication devices are
increasingly demanding. Cellular networks serve densely populated urban
areas, wireless LANs need to be able to cover large buildings with several
offices, low-power wireless sensors must tolerate noisy industrial
environments, batteries need to remain operational under various external
conditions, and so on.

The propagation of radio signals, the movement of communicating agents,
battery exhaustion, etc., depend on the surrounding physical environment.
For example, signals can be absorbed by objects, can pass through objects,
can be refracted by surfaces, can be reflected from surfaces, or battery
nominal capacity might depend on external temperature. These effects cannot
be ignored in high-fidelity simulations.

In order to help the modeling process, the model of the physical
environment is separated from the rest of the simulation models. The main
goal of the physical environment model is to describe buildings, walls,
vegetation, terrain, weather, and other physical objects and conditions
that might have effects on radio signal propagation, movement, batteries,
etc. This separation makes the model reusable by all other simulation
models that depend on these circumstances.

The following sections provide a brief overview of the physical environment
model.

\section{The Physical Environment Model}

The physical environment is represented in an INET simulation by a
\nedtype{PhysicalEnvironment} module. This module normally has one instance
in the network, and acts as a database that other parts of the simulation
can query at runtime.

\section{Global Physical Properties}

The physical environment model stores the following global
properties:

\begin{itemize}
  \item \textit{space limits}: global bounds for the 3-dimensional space
  \item \textit{temperature}: global parameter for temperature-dependent models
\end{itemize}

Space limits are useful for limiting the propagation and reflection of
radio signals, to constrain movement of communicating agents, and for
detecting incorrectly positioned physical objects.

Temperature can be useful for modeling batteries, as it affects the
maximum capacity, internal resistance, self-discharge and other properties
of real-life electrochemical energy storage devices.

\section{Physical Objects}

The most important aspect of the physical environment is the objects which
are present in it. For example, simulating an indoor Wifi scenario may need
to model walls, floors, ceilings, doors, windows, furniture, and similar
objects, because they all affect signal propagation.

Objects are located in space, and have shapes and materials. The INET
physical layer infrastructure supports basic shapes and homogeneous
materials, which simplifies description and still allows for a reasonable
approximation of reality. Physical objects in INET have the following
properties:

\begin{itemize}
  \item \textit{shape}: describes the 3-dimensional shape of the object,
    independent of its position and orientation
  \item \textit{position}: determines where the object is located in the 3-dimensional space
  \item \textit{orientation}: determines how the object is rotated relative to its
    default orientation
  \item \textit{material}: describes material-specific physical properties
  \item \textit{graphical properties}: provides parameters for better visualization
\end{itemize}

Physical objects in INET are stationary, they cannot change their position
or orientation over time.

Since the shape of the physical objects might be quite diverse, the model
is designed to be extensible with new shapes. Concave shapes are not yet
supported, such shapes can be represented by splitting them up into smaller,
convex parts. The current implementation provides the following shapes:

\begin{itemize}
  \item \textit{sphere}: specified by a radius
  \item \textit{cuboid}: specified by a length, a width, and a height
  \item \textit{prism}: specified by a 2-dimensional polygon base and a height
  \item \textit{polyhedron}: specified by the convex hull of a set of
    3-dimensional vertices
\end{itemize}

\section{Visualization}

The \nedtype{PhysicalEnvironment} module is capable is visualizing the objects on the
user interface. Rendering makes use of the following graphical object properties:

\begin{itemize}
  \item \textit{line width}: affects surface outline
  \item \textit{line color}: affects surface outline
  \item \textit{fill color}: affects surface fill
  \item \textit{opacity}: affects surface outline and fill
  \item \textit{tags}: allows filtering objects on the graphical user interface
\end{itemize}

The projection of 3D objects to the 2D canvas can be parameterized with an
arbitrary view angle. The default view angle is the Z axis (i.e. top view).
The view angle can also be changed during runtime, by changing the
appropriate module parameter.

The projection mechanism can be accessed by other models (e.g. mobility
models) for their own visualizations.

\section{Specifying Physical Objects}

Physical objects are defined for the \nedtype{PhysicalEnvironment} module
in an XML document. The document format allows one to define physical objects
together with their properties, and one can also define shapes and materials
that are shared (i.e. referenced) by several objects.

The following example shows some shapes, materials and objects defined in XML:

\begin{verbatim}
<environment>
  <!-- shapes and materials -->
  <shape id="1" type="sphere" radius="10"/>
  <shape id="2" type="cuboid" size="20 30 40"/>
  <shape id="3" type="prism" height="100"
         points="0 0 100 0 100 100 0 100"/>
  <shape id="4" type="polyhedron"
         points="0 0 0 100 0 0 100 100 0 0 100 0 ..."/>
  <material id="1" resistivity="100"
         relativePermittivity="4.5" relativePermeability="1"/>

  <!-- an object that uses a previously defined shape and material -->
  <object position="min 100 200 0" orientation="45 -30 0"
          shape="1" material="1"
          line-color="0 0 0" fill-color="112 128 144" opacity="0.5"/>

  <!-- an object defined with an in-line shape -->
  <object position="min 100 200 0" orientation="45 -30 0"
          shape="cuboid 20 30 40" material="concrete"
          line-color="0 0 0" fill-color="112 128 144" tags="Building"/>
</environment>
\end{verbatim}

For more details, please refer to the documentation of the
\nedtype{PhysicalEnvironment} module.

\section{Data Structure}

In order to model the physical environment in detail, a scenario might contain
several thousands or even more physical objects. Simulation models might
need to query these objects quite often. For example, when the physical layer
computes obstacle loss for a transmission, it needs to find the obstructing
physical objects for each receiver. This requires computing the intersection
between physical objects and the path traveled by the radio signal.

To speed up the computation of intersections, INET stores physical objects
in a highly efficient data structure, which currently can be one of the
following:

\begin{itemize}
  \item \nedtype{GridObjectCache}: organizes objects into a 3D spatial grid with
    a configurable constant cell size, where cells contain the objects that
    intersect with them
  \item \nedtype{BVHObjectCache}: organizes objects into a 3D tree, where
    leaves contain a configurable number of closely positioned objects.
    (This data structure is similar to quadtree and octree, but is designed for
    storing finite-sized objects.)
\end{itemize}

The physical environment model uses \nedtype{GridObjectCache} by default.

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "usman"
%%% End:

